<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Axios-post</title>
	</head>
	<body>
		
		
		
		<script src="../js/axios.js"></script>
		<script>
			let url = "http://127.0.0.1:8090/axios/user1"
			let id = 1
			let name = '黑熊精'
			let age = 3000
			let sex = '男'
			
			//1 后端不使用@RequestBody 500 后端使用@RequestBody 415
			let param1 = `{"id":${id},"name":"${name}","age":${age},"sex":"${sex}"}`
			//2 后端不使用@RequestBody 可以正常接收 使用注解报415
			let param2=`name=${name}&age=${age}&sex=${sex}`
			
			//3 后端不使用@RequestBody 可以正常接收 使用注解报415
			let param3 = new URLSearchParams()//URLSearchParams
			// param3.append("id",id)
			param3.append("name",name)
			param3.append("age",age)
			param3.append("sex",sex)
			//4 后端使用@RequestBody 可以正常接收 这里传递js对象 后端接收到的是json 然后用注解转化为java对象
			let param4 = {//对象
				name:name,
				age:age,
				sex:sex
			}
			
			axios.post(url,param3)
			.then(result=>{
				console.log(result.data)
			})
			
			
		</script>
	</body>
</html>
